package cn.tedu.mall.front.service.impl;

import cn.tedu.mall.common.exception.CoolSharkServiceException;
import cn.tedu.mall.common.restful.ResponseCode;
import cn.tedu.mall.front.mapper.FrontSpuMapper;
import cn.tedu.mall.front.service.IFrontAttributeService;
import cn.tedu.mall.pojo.front.vo.SelectAttributeVO;
import cn.tedu.mall.pojo.product.vo.AttributeStandardVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class FrontAttributeServiceImpl implements IFrontAttributeService {

    @Autowired
    private FrontSpuMapper spuMapper;

    @Override
    public SelectAttributeVO getAllRelatedAttirbutes(Long categoryId) {
        return null;
    }

    @Override
    public List<AttributeStandardVO> getSpuAttributesBySpuId(Long id) {
        List<AttributeStandardVO> attributeStandardVOList = spuMapper.selectAttributesBySpuId(id);
        if (attributeStandardVOList == null){
            throw new CoolSharkServiceException(ResponseCode.NOT_FOUND,"当前spu没有属性");
        }
        return attributeStandardVOList;
    }
}
